package Enum_;

/**
 * @author 王艺锡
 * @version 1.0
 * 枚举方法的使用
 */
public class EnumExercise {
    public static void main(String[] args) {
        Season02 autumn = Season02.AUTUMN;
        //name()方法，输出名字
        System.out.println(autumn.name());

        //ordinal()输出的是该枚举对象的编号(从0开始)
        System.out.println(autumn.ordinal());

        //values()方法，可以返回一个数组，里面包含所有枚举对象。
        Season02[] values = Season02.values();
        //增强for循环
        for(Season02 season02:values){
            System.out.println(season02);
        }

        //valueOf()方法,根据你输入的"AUTUMN"到Season02中去查询
        //如果找到了就返回，如果找不到就报错
        Season02 season02 = Season02.valueOf("AUTUMN");
        System.out.println(season02);
        System.out.println(season02 == autumn);

        //compareTo()方法
        //就是把Season02.WINTER的编号和Season02.SUMMER的编号进行对比
        //Season02.WINTER的编号 - Season02.SUMMER的编号(3-1)
        System.out.println(Season02.WINTER.compareTo(Season02.SUMMER));

    }
}
